UDP查询设备信息static void Main(string[] args)
{
UdpClient client = new UdpClient();
client.JoinMulticastGroup(IPAddress.Parse("224.0.0.1"));
IPEndPoint broadcastIp = new IPEndPoint(IPAddress.Parse("224.0.0.1"), 19601);
string mess = "{ \"cmd\": \"hopediscover\", \"params\": { \"deviceid\": \"e076d092265b\" } }";
byte[] buf = Encoding.Default.GetBytes(mess);
Thread t = new Thread(new ThreadStart(RecvThread));
t.IsBackground = true;
t.Start();
while (true)
{
client.Send(buf, buf.Length, broadcastIp);
System.Threading.Thread.Sleep(1000);
}
}
评论